const arr1 = [1, 3, 4, 6, 7];
const arr2 = [2, 5, 3, 6, 1];
// 交集
function getIntersection(arr1, arr2) {
  return arr1.filter((value) => arr2.includes(value));
}

const intersection = getIntersection(arr1, arr2);
console.log(intersection);  // 输出：[1, 3, 6]

// 并集
function getUnion(arr1, arr2) {
  return [...new Set([...arr1, ...arr2])];
}

const union = getUnion(arr1, arr2);
console.log(union);  // 输出：[1, 3, 4, 6, 7, 2, 5]